package com.qianfeng.biz.impl;

import java.util.List;

import com.qianfeng.biz.IOrderBiz;
import com.qianfeng.dao.IOrderDao;
import com.qianfeng.dao.impl.OrderDaoImpl;
import com.qianfeng.dto.PageBean;
import com.qianfeng.entity.Order;
import com.qianfeng.entity.OrderDetail;
import com.qianfeng.entity.User;

public class OrderBizImpl implements IOrderBiz {
	
	private IOrderDao orderDao = new OrderDaoImpl();

	@Override
	public void addOrder(Order order) {
		orderDao.addOrder(order);
	}

	@Override
	public Order getOrderById(int orderid) {
		return orderDao.getOrderById(orderid);
	}

	@Override
	public PageBean queryall(int currPage) {
		PageBean pb=new PageBean();
		int count=orderDao.querycount();
		int pageSize=4;
		int rowIndex=(currPage-1)*pageSize;
		double ct=count;
		Double tp=Math.ceil(ct/pageSize);
		int totalPage=tp.intValue();
		List<Order> list=orderDao.queryfenye(rowIndex,pageSize);
		pb.setTotalPage(totalPage);
		pb.setTotalCount(count);
		pb.setCurrPage(currPage);
		pb.setPageSize(pageSize);
		pb.setList(list);
		return pb;
	}

	
}
